package mapred.config;

import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapred.Mapper;
import org.apache.hadoop.mapred.lib.IdentityMapper;

@SuppressWarnings("unchecked")
public class MapConfig {

    private Class<? extends Mapper> mapperClass;

    private Class<? extends Writable> outputKeyClass;

    private Class<? extends Writable> outputValueClass;

    private MapConfig(Class<? extends Mapper> mapperClass,
            Class<? extends Writable> outputKeyClass,
            Class<? extends Writable> outputValueClass) {
        if (mapperClass == null) {
            this.mapperClass = IdentityMapper.class;
        } else {
            this.mapperClass = mapperClass;
        }
        this.outputKeyClass = outputKeyClass;
        this.outputValueClass = outputValueClass;
    }

    public static MapConfig newInstance(Class<? extends Mapper> mapperClass,
            Class<? extends Writable> outputKeyClass,
            Class<? extends Writable> outputValueClass) {
        return new MapConfig(mapperClass, outputKeyClass, outputValueClass);
    }

    public Class<? extends Mapper> getMapperClass() {
        return mapperClass;
    }

    public Class<? extends Writable> getOutputKeyClass() {
        return outputKeyClass;
    }

    public Class<? extends Writable> getOutputValueClass() {
        return outputValueClass;
    }

}
